/*
 * ClientesForm.java
 *
 * Created on 1 de julio de 2008, 02:45
 */

package View;

import javax.swing.UIManager;
import com.birosoft.liquid.*;
//import Servicio.ReporteClientes;
import Controller.RPedidoController;
import Model.Cliente; 
import Reportes.*;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.JFrame;
import java.lang.String;
import java.util.Vector;
/**
 *
 * @author  javiten
 */
public class ClientesForm extends javax.swing.JFrame {
    private PpalForm ppal;
    // Controller del Form
    private RPedidoController mRPedidoController;
//    private ReporteClientes repClientes;
    private javax.swing.DefaultComboBoxModel modeloCombo = new javax.swing.DefaultComboBoxModel();
    
    private ArrayList<String> mClientes;
    private Cliente mCliente;
    
    private Vector cli;
    /** Creates new form ClientesForm */
    public ClientesForm() {
        //Se crea el controller de la pantalla
        mRPedidoController = new RPedidoController();
        try {
            UIManager.setLookAndFeel("com.birosoft.liquid.LiquidLookAndFeel");   
        } catch (Exception e) { }
        LiquidLookAndFeel.setStipples(false);
        initComponents();
        jComboNombre.setModel(modeloCombo);
        this.setSize(this.getMaximumSize());
       
            // Crea el arrayList de ClientesForm
         mRPedidoController.cargarClientes();
        
         // Crea el arrayList de Congresos
         mRPedidoController.cargarCongresos();
         
         // Carga el Combo de las especialidades.
         mRPedidoController.cargarEspecialidades();
         
         // Carga el Combo de las localidades.
         mRPedidoController.cargarLocalidades();
         
         // Carga el Combo de las Provincias.
         mRPedidoController.cargarProvincias();
         
         // Carga el Combo de los paises.
         mRPedidoController.cargarPaises();
         
         
         // Crea el arrayList de Apellidos de los ClientesForm
         mRPedidoController.cargarApellidos();
         
         // Crea el combo de Apellidos de clientes
         mClientes = mRPedidoController.getApellidos();
         
         // Carga el Combo de las especialidades.
         mRPedidoController.cargarEspecialidades();
         mRPedidoController.cargadatosCombo(jComboEspecialidad, mRPedidoController.getEspecialidades());
         // Carga el Combo de las localidades.
         mRPedidoController.cargarLocalidades();
         mRPedidoController.cargadatosCombo(jComboLocalidad, mRPedidoController.getLocalidades());
         // Carga el Combo de las localidades.
         mRPedidoController.cargarProvincias();
         mRPedidoController.cargadatosCombo(jComboProvincia, mRPedidoController.getProvincias());
         // Carga el Combo de las localidades.
         mRPedidoController.cargarPaises();
         mRPedidoController.cargadatosCombo(jComboPais, mRPedidoController.getPaises());
         
         
         //Carga el combo de los Apellidos.
         mRPedidoController.cargaCombos(jComboApellido,mRPedidoController.getApellidos());
         //Carga el combo de las especialidades.
         mRPedidoController.cargaCombos(jComboEspecialidad, mRPedidoController.getEspecialidades());
         //Carga el combo de las Localidades.
         mRPedidoController.cargaCombos(jComboLocalidad, mRPedidoController.getLocalidades());
         //Carga el combo de las Provincias.
         mRPedidoController.cargaCombos(jComboProvincia, mRPedidoController.getProvincias());
         //Carga el combo de los Paises.
         mRPedidoController.cargaCombos(jComboPais, mRPedidoController.getPaises());
    
     
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelTitulo = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jPanelCliente = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jComboTipoDoc = new javax.swing.JComboBox();
        jTextDoc = new javax.swing.JTextField();
        jTextMatricula = new javax.swing.JTextField();
        jTextMail = new javax.swing.JTextField();
        jTextDireccion = new javax.swing.JTextField();
        jComboEspecialidad = new javax.swing.JComboBox();
        jComboPais = new javax.swing.JComboBox();
        jButtonHistorial = new javax.swing.JButton();
        jTextCp = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jTextHobbie = new javax.swing.JTextField();
        jButtonAcepta = new javax.swing.JButton();
        jComboApellido = new javax.swing.JComboBox();
        jComboNombre = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        jComboDiaNac = new javax.swing.JComboBox();
        jComboMesNac = new javax.swing.JComboBox();
        jComboAnioNac = new javax.swing.JComboBox();
        jLabel21 = new javax.swing.JLabel();
        jTextTelFijo = new javax.swing.JTextField();
        jTextTelMovil = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        jComboLocalidad = new javax.swing.JComboBox();
        jComboProvincia = new javax.swing.JComboBox();
        jButtonLimpiar = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListClientes = new javax.swing.JList();
        jButtonExcel = new javax.swing.JButton();
        jTextExcel = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel11.setFont(new java.awt.Font("Monotype Corsiva", 1, 24));
        jLabel11.setForeground(new java.awt.Color(94, 148, 189));
        jLabel11.setText("CARGAR NUEVO CLIENTE");

        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/logo_GTV4.gif"))); // NOI18N

        jPanelCliente.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "CLIENTE", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Verdana", 1, 12), new java.awt.Color(94, 148, 189))); // NOI18N
        jPanelCliente.setForeground(new java.awt.Color(255, 204, 204));

        jLabel1.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel1.setText("Nombre");

        jLabel2.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel2.setText("Apellido");

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel3.setText("Documento");

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel4.setText("Matrícula");

        jLabel5.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel5.setText("Especialidad");

        jLabel6.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel6.setText("Dirección");

        jLabel7.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel7.setText("Localidad");

        jLabel8.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel8.setText("CP");

        jLabel9.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel9.setText("Provincia");

        jLabel10.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel10.setText("País");

        jComboTipoDoc.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboTipoDoc.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "DNI", "PASS", "CED", "OTRO" }));

        jTextDoc.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextDoc.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextDocKeyReleased(evt);
            }
        });

        jTextMatricula.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextMatricula.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextMatriculaKeyReleased(evt);
            }
        });

        jTextMail.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextMail.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextMailKeyReleased(evt);
            }
        });

        jTextDireccion.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextDireccion.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextDireccionKeyReleased(evt);
            }
        });

        jComboEspecialidad.setEditable(true);
        jComboEspecialidad.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboEspecialidad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "" }));
        jComboEspecialidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboEspecialidadActionPerformed(evt);
            }
        });

        jComboPais.setEditable(true);
        jComboPais.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboPais.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "" }));

        jButtonHistorial.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonHistorial.setForeground(new java.awt.Color(94, 148, 189));
        jButtonHistorial.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Historial_normal.gif"))); // NOI18N
        jButtonHistorial.setToolTipText("Ver historial de pedidos del cliente");
        jButtonHistorial.setBorderPainted(false);
        jButtonHistorial.setContentAreaFilled(false);
        jButtonHistorial.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Historial_deshabilitado.gif"))); // NOI18N
        jButtonHistorial.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Historial_presionado.gif"))); // NOI18N
        jButtonHistorial.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Historial_mouse.gif"))); // NOI18N
        jButtonHistorial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonHistorialActionPerformed(evt);
            }
        });

        jTextCp.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextCp.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextCpActionPerformed(evt);
            }
        });

        jLabel19.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel19.setText("Mail");

        jLabel20.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel20.setText("Hobbie");

        jTextHobbie.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextHobbie.setText(" ");
        jTextHobbie.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextHobbieKeyReleased(evt);
            }
        });

        jButtonAcepta.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonAcepta.setForeground(new java.awt.Color(94, 148, 189));
        jButtonAcepta.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_normal.gif"))); // NOI18N
        jButtonAcepta.setToolTipText("Guardar cliente");
        jButtonAcepta.setBorderPainted(false);
        jButtonAcepta.setContentAreaFilled(false);
        jButtonAcepta.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_deshabilitado.gif"))); // NOI18N
        jButtonAcepta.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_presionado.gif"))); // NOI18N
        jButtonAcepta.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Aceptar_mouse.gif"))); // NOI18N
        jButtonAcepta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonAceptaActionPerformed(evt);
            }
        });

        jComboApellido.setEditable(true);
        jComboApellido.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboApellido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboApellidoActionPerformed(evt);
            }
        });

        jComboNombre.setEditable(true);
        jComboNombre.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboNombre.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jComboNombreItemStateChanged(evt);
            }
        });

        jLabel18.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel18.setText("Fecha de nacimiento");

        jComboDiaNac.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboDiaNac.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31" }));

        jComboMesNac.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboMesNac.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" }));

        jComboAnioNac.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboAnioNac.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "1910", "1911", "1912", "1913", "1914", "1915", "1916", "1917", "1918", "1919", "1920", "1921", "1922", "1923", "1924", "1925", "1926", "1927", "1928", "1929", "1930", "1931", "1932", "1933", "1934", "1935", "1936", "1937", "1938", "1939", "1940", "1941", "1942", "1943", "1944", "1945", "1946", "1947", "1948", "1949", "1950", "1951", "1952", "1953", "1954", "1955", "1956", "1957", "1958", "1959", "1960", "1961", "1962", "1963", "1964", "1965", "1966", "1967", "1968", "1969", "1970", "1971", "1972", "1973", "1974", "1975", "1976", "1977", "1978", "1979", "1980", "1981", "1982", "1983", "1984", "1985", "1986", "1987", "1988", "1989", "1990", "1991", "1992", "1993", "1994", "1995", "1996", "1997", "1998", "1999", "2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008" }));

        jLabel21.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel21.setText("Teléfono fijo");

        jTextTelFijo.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextTelFijo.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextTelFijoKeyReleased(evt);
            }
        });

        jTextTelMovil.setFont(new java.awt.Font("Verdana", 0, 10));
        jTextTelMovil.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jTextTelMovilKeyReleased(evt);
            }
        });

        jLabel22.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel22.setText("Teléfono móvil");

        jComboLocalidad.setEditable(true);
        jComboLocalidad.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboLocalidad.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "" }));

        jComboProvincia.setEditable(true);
        jComboProvincia.setFont(new java.awt.Font("Verdana", 0, 10));
        jComboProvincia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "" }));

        jButtonLimpiar.setFont(new java.awt.Font("Verdana", 1, 10));
        jButtonLimpiar.setForeground(new java.awt.Color(94, 148, 189));
        jButtonLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Limpiar_normal.gif"))); // NOI18N
        jButtonLimpiar.setToolTipText("Poner en blanco los renglones");
        jButtonLimpiar.setBorderPainted(false);
        jButtonLimpiar.setContentAreaFilled(false);
        jButtonLimpiar.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Lipiar_deshabilitado.gif"))); // NOI18N
        jButtonLimpiar.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Limpiar_presionado.gif"))); // NOI18N
        jButtonLimpiar.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Limpiar_mouse.gif"))); // NOI18N
        jButtonLimpiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonLimpiarActionPerformed(evt);
            }
        });

        jButton1.setFont(new java.awt.Font("Verdana", 1, 10));
        jButton1.setForeground(new java.awt.Color(94, 148, 189));
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_normal.gif"))); // NOI18N
        jButton1.setToolTipText("Volver a la pantalla principal");
        jButton1.setBorderPainted(false);
        jButton1.setContentAreaFilled(false);
        jButton1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_deshabilitado.gif"))); // NOI18N
        jButton1.setFocusPainted(false);
        jButton1.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_presionado.gif"))); // NOI18N
        jButton1.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Volver_mouse.gif"))); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelClienteLayout = new javax.swing.GroupLayout(jPanelCliente);
        jPanelCliente.setLayout(jPanelClienteLayout);
        jPanelClienteLayout.setHorizontalGroup(
            jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelClienteLayout.createSequentialGroup()
                .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelClienteLayout.createSequentialGroup()
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel18)
                            .addComponent(jLabel21)
                            .addComponent(jLabel22)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel19)
                            .addComponent(jLabel7)
                            .addComponent(jLabel9)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jComboProvincia, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboLocalidad, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jTextTelMovil)
                            .addComponent(jTextCp)
                            .addComponent(jTextDireccion)
                            .addComponent(jTextMail)
                            .addComponent(jComboEspecialidad, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jTextMatricula)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelClienteLayout.createSequentialGroup()
                                .addComponent(jComboTipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextDoc))
                            .addComponent(jTextTelFijo)
                            .addComponent(jComboNombre, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jComboApellido, javax.swing.GroupLayout.Alignment.TRAILING, 0, 274, Short.MAX_VALUE)
                            .addGroup(jPanelClienteLayout.createSequentialGroup()
                                .addGap(10, 10, 10)
                                .addComponent(jComboDiaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboMesNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jComboAnioNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addGroup(jPanelClienteLayout.createSequentialGroup()
                        .addGap(77, 77, 77)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel20)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanelClienteLayout.createSequentialGroup()
                                .addComponent(jButtonLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButtonHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jComboPais, 0, 262, Short.MAX_VALUE)
                            .addComponent(jTextHobbie)))
                    .addGroup(jPanelClienteLayout.createSequentialGroup()
                        .addGap(185, 185, 185)
                        .addComponent(jButtonAcepta, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(53, 53, 53)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanelClienteLayout.setVerticalGroup(
            jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelClienteLayout.createSequentialGroup()
                .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanelClienteLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanelClienteLayout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(jComboApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel18)
                            .addComponent(jComboDiaNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboMesNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jComboAnioNac, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel21)
                            .addComponent(jTextTelFijo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel22)
                            .addComponent(jTextTelMovil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jComboTipoDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(jTextDoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jTextMatricula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(jComboEspecialidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel19)
                            .addComponent(jTextMail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelClienteLayout.createSequentialGroup()
                                .addGap(32, 32, 32)
                                .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel7)
                                    .addComponent(jComboLocalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jTextDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel6)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(jComboProvincia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextCp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(jComboPais, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel20)
                            .addComponent(jTextHobbie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButtonAcepta, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanelClienteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jButtonHistorial, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButtonLimpiar, javax.swing.GroupLayout.PREFERRED_SIZE, 26, Short.MAX_VALUE))))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanelTituloLayout = new javax.swing.GroupLayout(jPanelTitulo);
        jPanelTitulo.setLayout(jPanelTituloLayout);
        jPanelTituloLayout.setHorizontalGroup(
            jPanelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTituloLayout.createSequentialGroup()
                .addGroup(jPanelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTituloLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel12)
                        .addGap(42, 42, 42)
                        .addComponent(jLabel11))
                    .addComponent(jPanelCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelTituloLayout.setVerticalGroup(
            jPanelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelTituloLayout.createSequentialGroup()
                .addGroup(jPanelTituloLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelTituloLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel12))
                    .addGroup(jPanelTituloLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addComponent(jLabel11)))
                .addGap(19, 19, 19)
                .addComponent(jPanelCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jListClientes);

        jButtonExcel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_normal.gif"))); // NOI18N
        jButtonExcel.setBorderPainted(false);
        jButtonExcel.setContentAreaFilled(false);
        jButtonExcel.setDefaultCapable(false);
        jButtonExcel.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_deshabilitado.gif"))); // NOI18N
        jButtonExcel.setPressedIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_presionado.gif"))); // NOI18N
        jButtonExcel.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/Botones/Excel_mouse.gif"))); // NOI18N
        jButtonExcel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExcelActionPerformed(evt);
            }
        });

        jTextExcel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextExcelActionPerformed(evt);
            }
        });

        jLabel13.setFont(new java.awt.Font("Verdana", 0, 10));
        jLabel13.setText("Nombre del archivo:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanelTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 153, Short.MAX_VALUE)
                        .addContainerGap(99, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel13)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jTextExcel)
                                .addComponent(jButtonExcel, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(125, 125, 125)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 304, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(27, 27, 27)
                        .addComponent(jLabel13)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextExcel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButtonExcel, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(243, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButtonHistorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonHistorialActionPerformed
   if (validarCampos()){ 
    DetallesForm gForm = new DetallesForm(this, true, nuevoCliente(),this,null);
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension screenSize = tk.getScreenSize();
    int screenHeight = screenSize.height;
    int screenWidth = screenSize.width;
    gForm.setLocation(screenWidth / 4, screenHeight / 4);
    gForm.setVisible(true);
   }
   
}//GEN-LAST:event_jButtonHistorialActionPerformed

private void jTextCpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextCpActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextCpActionPerformed

private boolean validarCampos(){
   

   try{
    if (((String)this.jComboApellido.getSelectedItem()).compareTo("")==0 ){
        JOptionPane.showMessageDialog(new JFrame(), "Debe ingresar un Apellido", "Atención!", JOptionPane.WARNING_MESSAGE);
        return false;
    }
   } catch (Exception e) { 
        JOptionPane.showMessageDialog(new JFrame(), "Debe ingresar un Apellido", "Atención!", JOptionPane.WARNING_MESSAGE);
        return false;
        }
   

   try{
   if (((String)this.jComboNombre.getSelectedItem()).compareTo("")==0 ){
        JOptionPane.showMessageDialog(new JFrame(), "Debe ingresar un Nombre", "Atención!", JOptionPane.WARNING_MESSAGE);
        return false;
    } 
   } catch (Exception e) { 
       try{
       Cliente c = ((Cliente)this.jComboNombre.getSelectedItem());
        if (c.getNombreCli().compareToIgnoreCase("")==0) {
           JOptionPane.showMessageDialog(new JFrame(), "Debe ingresar un Nombre", "Atención!", JOptionPane.WARNING_MESSAGE);  
        }   

       }catch(Exception e2){
       JOptionPane.showMessageDialog(new JFrame(), "Debe ingresar un Nombre", "Atención!", JOptionPane.WARNING_MESSAGE);
        return false;
       }
   }
        
    
    if (jTextCp.getText().compareTo("") != 0){
        try{
            Integer.parseInt(this.jTextCp.getText());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(new JFrame(), "Debe ingresar un Codigo Postal valido ", "Atención!", JOptionPane.WARNING_MESSAGE);
            return false;
        }
    }
    
    if (jTextDoc.getText().compareTo("") != 0){
        try{
            Integer.parseInt(this.jTextDoc.getText());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(new JFrame(), "Debe ingresar un Numero de documento valido ", "Atención!", JOptionPane.WARNING_MESSAGE);
        return false;
        }
    }
  return true;


}


/** Habilita o deshabilita los componentes del panel de Clientes */
    public void panelClienteEstado(boolean estado){
            jComboApellido.setEnabled(estado);
            jComboNombre.setEnabled(estado);
            jComboTipoDoc.setEnabled(estado);
            jTextDoc.setEnabled(estado);
            jComboDiaNac.setEnabled(estado);
            jComboMesNac.setEnabled(estado);
            jComboAnioNac.setEnabled(estado);
            jTextTelFijo.setEnabled(estado);
            jTextTelMovil.setEnabled(estado);
            jTextMatricula.setEnabled(estado);
            jComboEspecialidad.setEnabled(estado);
            jTextMail.setEnabled(estado);
            jTextDireccion.setEnabled(estado);
            jComboLocalidad.setEnabled(estado);
            jComboProvincia.setEnabled(estado);
            jTextCp.setEnabled(estado);
            jComboPais.setEnabled(estado);
            jTextHobbie.setEnabled(estado);
            jButtonHistorial.setEnabled(estado);
            jButtonAcepta.setEnabled(estado);
            jButtonLimpiar.setEnabled(estado);
    }
   

/** Crea el Cliente del Pedido*/
private Cliente nuevoCliente(){
  //double doc;
  int cp;
  String fechaNac;
   
  /*if (jTextDoc.getText().isEmpty()) 
      doc = 0;
  else 
      doc = Double.parseDouble(jTextDoc.getText());*/

  if (jTextCp.getText().isEmpty())
      cp = 0;
  else
      cp = Integer.parseInt(jTextCp.getText().toString());
   
   if (jComboAnioNac.getSelectedItem().toString().compareTo("")==0 ||
    jComboMesNac.getSelectedItem().toString().compareTo("")==0 ||
    jComboDiaNac.getSelectedItem().toString().compareTo("")==0)
       fechaNac="";
   else
        fechaNac = jComboAnioNac.getSelectedItem().toString()+"-"+
                jComboMesNac.getSelectedItem().toString()+"-"+
                jComboDiaNac.getSelectedItem().toString()+" 00:00:00";
  String nom;
  try{
      nom = ((Cliente)jComboNombre.getSelectedItem()).getNombreCli();
  }catch (Exception e){
      nom = jComboNombre.getSelectedItem().toString();
  }
      
  
    mCliente = new Cliente( jComboTipoDoc.getSelectedItem().toString(),
           jTextDoc.getText() , (String) jComboApellido.getSelectedItem(),
           nom, fechaNac, jTextTelFijo.getText(), 
           jTextTelMovil.getText(), jTextMatricula.getText(), jTextMail.getText(),
           jTextDireccion.getText(), jComboEspecialidad.getSelectedItem().toString(),
           cp, jComboLocalidad.getSelectedItem().toString(),jComboProvincia.getSelectedItem().toString(), 
           jComboPais.getSelectedItem().toString(), jTextHobbie.getText());
  
    
    
    
   return mCliente;
  
}

private void jButtonAceptaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAceptaActionPerformed
// Validar campos ingresados!!!!!!
    if (validarCampos()) {
    
    //Crea el nuevo Cliente. y lo agrega en la base de datos.
     try{   
     mRPedidoController.setCliente(nuevoCliente());
     mRPedidoController.agregarCliente ();
     this.jButtonHistorial.setEnabled(true);
     JOptionPane.showMessageDialog(new JFrame(), "El Cliente se ha almacenado correctamente", "Atención!", JOptionPane.INFORMATION_MESSAGE);
     limpiarCliente();
            this.jComboNombre.setSelectedItem("");
            this.jComboApellido.setSelectedItem("");
            mRPedidoController.cargarClientes();
     }
     catch (Exception ex100) {
           JOptionPane.showMessageDialog(new JFrame(), "El Cliente no ha sido almacenado correctamente", "Atención!", JOptionPane.INFORMATION_MESSAGE);}
      }
    
}//GEN-LAST:event_jButtonAceptaActionPerformed

public void buscaComboApellido(){
        int buscaApellido=0;
        if(jComboApellido.getSelectedItem() != null)
            for (int i=0;i<mClientes.size();i++){
            if (((String)jComboApellido.getSelectedItem()).equalsIgnoreCase((String)mClientes.get(i))==true){
             buscaApellido=1;
            }
        }
       //jComboNombre.removeAllItems();
        modeloCombo.removeAllElements();
        if (buscaApellido==1){
            cargaComboNombres();
        }
    }

    //Carga el combo con nombres si el apellido fue reconocido.
    public void cargaComboNombres(){
        for(int i=0;i < mRPedidoController.getClientes().size();i++){
           if(mRPedidoController.getClientes().get(i).getApellidoCli().equalsIgnoreCase((String)jComboApellido.getSelectedItem())==true){
             jComboNombre.addItem(mRPedidoController.getClientes().get(i));
        }
    }}
private void jComboApellidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboApellidoActionPerformed
//cargaComboNombres();
    buscaComboApellido();
}//GEN-LAST:event_jComboApellidoActionPerformed

private void jComboNombreItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboNombreItemStateChanged
if (jComboNombre.getSelectedItem()!=null){
        try{
            Cliente auxCli= (Cliente)jComboNombre.getSelectedItem();
            this.jTextDoc.setText(auxCli.getNroDocumento());
            this.jTextCp.setText(String.valueOf(auxCli.getCP()));
            this.jTextDireccion.setText(auxCli.getDireccion());
            this.jComboLocalidad.setSelectedItem(auxCli.getLocalidad());
            this.jComboProvincia.setSelectedItem(auxCli.getProvincia());
            this.jComboPais.setSelectedItem(auxCli.getPais());
            this.jComboTipoDoc.setSelectedItem(auxCli.getTipoDocumento());
            this.jComboEspecialidad.setSelectedItem(auxCli.getEspecialidad());
            this.jTextMail.setText(auxCli.getMail());
            this.jTextMatricula.setText(auxCli.getMatricula());
            this.jTextTelFijo.setText(auxCli.getTelFijo());
            this.jTextTelMovil.setText(auxCli.getTelMovil()); 
            try {
            if (auxCli.getFechaNac().length()>0){
            this.jComboDiaNac.setSelectedItem(auxCli.getFechaNac().substring(8, 10));
            this.jComboMesNac.setSelectedItem(auxCli.getFechaNac().substring(5, 7));
            this.jComboAnioNac.setSelectedItem(auxCli.getFechaNac().substring(0, 4));
            }  }catch(Exception e2){
            this.jComboDiaNac.setSelectedItem("");
            this.jComboMesNac.setSelectedItem("");
            this.jComboAnioNac.setSelectedItem("");    
            }
            
        } catch (Exception e) {
            this.jTextDoc.setText("");
            this.jTextCp.setText("");
            this.jTextDireccion.setText("");
            this.jComboLocalidad.setSelectedItem("");
            this.jComboProvincia.setSelectedItem("");
            this.jComboPais.setSelectedItem("");
            this.jComboTipoDoc.setSelectedItem("");
            this.jComboEspecialidad.setSelectedItem("");
            this.jTextMail.setText("");
            this.jTextMatricula.setText("");
            this.jTextTelFijo.setText("");
            this.jTextTelMovil.setText(""); 
            this.jComboDiaNac.setSelectedItem("");
            this.jComboMesNac.setSelectedItem("");
            this.jComboAnioNac.setSelectedItem("");  
            
        }
    }// TODO add your handling code here:
}//GEN-LAST:event_jComboNombreItemStateChanged

//Si el cliente con el que se cargaron los datos no es el deseado, este es el metodo
//que se utiliza para borrar todos los datos de ese cliente y comenzar a completar lo demas.
private void limpiarCliente(){
         
            this.jTextDoc.setText("");
            this.jTextCp.setText("");
            this.jTextDireccion.setText("");
            this.jComboLocalidad.setSelectedItem("");
            this.jComboProvincia.setSelectedItem("");
            this.jComboPais.setSelectedItem("");
            this.jComboTipoDoc.setSelectedItem("");
            this.jComboEspecialidad.setSelectedItem("");
            this.jTextMail.setText("");
            this.jTextMatricula.setText("");
            this.jTextTelFijo.setText("");
            this.jTextTelMovil.setText(""); 
            this.jComboDiaNac.setSelectedItem("");
            this.jComboMesNac.setSelectedItem("");
            this.jComboAnioNac.setSelectedItem("");
}


private void jButtonLimpiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonLimpiarActionPerformed
limpiarCliente();
}//GEN-LAST:event_jButtonLimpiarActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        ppal.cargarFormulario();
        this.dispose();

}//GEN-LAST:event_jButton1ActionPerformed

private void jTextDocKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextDocKeyReleased
if(jTextDoc.getText().length()>10){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima del Documento es de 10 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextDoc.setText(jTextDoc.getText().substring(0,10));
    }
}//GEN-LAST:event_jTextDocKeyReleased

private void jTextTelFijoKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextTelFijoKeyReleased
 if(jTextTelFijo.getText().length()>30){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 30 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextTelFijo.setText(jTextTelFijo.getText().substring(0,30));
    }
}//GEN-LAST:event_jTextTelFijoKeyReleased

private void jTextTelMovilKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextTelMovilKeyReleased
if(jTextTelMovil.getText().length()>30){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 30 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextTelMovil.setText(jTextTelMovil.getText().substring(0,30));
    }
}//GEN-LAST:event_jTextTelMovilKeyReleased

private void jTextMatriculaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextMatriculaKeyReleased
if(jTextMatricula.getText().length()>20){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 20 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextMatricula.setText(jTextMatricula.getText().substring(0,20));
    }
}//GEN-LAST:event_jTextMatriculaKeyReleased

private void jTextMailKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextMailKeyReleased
if(jTextMail.getText().length()>40){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 40 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextMail.setText(jTextMail.getText().substring(0,40));
    }
}//GEN-LAST:event_jTextMailKeyReleased

private void jTextDireccionKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextDireccionKeyReleased
if(jTextDireccion.getText().length()>50){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 50 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextDireccion.setText(jTextDireccion.getText().substring(0,50));
    }
}//GEN-LAST:event_jTextDireccionKeyReleased

private void jTextHobbieKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextHobbieKeyReleased
if(jTextHobbie.getText().length()>30){
            JOptionPane.showMessageDialog(new JFrame(), "La longitud máxima es de 30 caracteres"," ", JOptionPane.INFORMATION_MESSAGE);
            jTextHobbie.setText(jTextHobbie.getText().substring(0,30));
    }
}//GEN-LAST:event_jTextHobbieKeyReleased

private void jComboEspecialidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboEspecialidadActionPerformed
    Vector Clientes = new Vector();
    if ((String)jComboEspecialidad.getSelectedItem() != null){
        for(int i=0; i < mRPedidoController.getClientes().size() ;i++){
            if (mRPedidoController.getClientes().get(i).getEspecialidad().compareTo((String)jComboEspecialidad.getSelectedItem())==0 && jComboEspecialidad.getSelectedItem().toString().compareTo("")!=0){
                //Clientes.add((String)mRPedidoController.getClientes().get(i).getApellidoCli() + ", " + (String)mRPedidoController.getClientes().get(i).getNombreCli());
                Clientes.add(mRPedidoController.getClientes().get(i));
        }
    jListClientes.setListData(Clientes);
    cli=Clientes;
    }
}//GEN-LAST:event_jComboEspecialidadActionPerformed
}

private void jButtonExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExcelActionPerformed
if (jTextExcel.getText().compareTo("")!=0){
    ManejaExcel excel= new generaClientes(jTextExcel.getText(),"2005-11-11","2029-05-05",4,(String)jComboEspecialidad.getSelectedItem());
    excel.generaReporte();
}
}//GEN-LAST:event_jButtonExcelActionPerformed

private void jTextExcelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextExcelActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTextExcelActionPerformed


public void setPpal(PpalForm p){
        this.ppal=p;
}


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButtonAcepta;
    private javax.swing.JButton jButtonExcel;
    private javax.swing.JButton jButtonHistorial;
    private javax.swing.JButton jButtonLimpiar;
    private javax.swing.JComboBox jComboAnioNac;
    private javax.swing.JComboBox jComboApellido;
    private javax.swing.JComboBox jComboDiaNac;
    private javax.swing.JComboBox jComboEspecialidad;
    private javax.swing.JComboBox jComboLocalidad;
    private javax.swing.JComboBox jComboMesNac;
    private javax.swing.JComboBox jComboNombre;
    private javax.swing.JComboBox jComboPais;
    private javax.swing.JComboBox jComboProvincia;
    private javax.swing.JComboBox jComboTipoDoc;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jListClientes;
    private javax.swing.JPanel jPanelCliente;
    private javax.swing.JPanel jPanelTitulo;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextCp;
    private javax.swing.JTextField jTextDireccion;
    private javax.swing.JTextField jTextDoc;
    private javax.swing.JTextField jTextExcel;
    private javax.swing.JTextField jTextHobbie;
    private javax.swing.JTextField jTextMail;
    private javax.swing.JTextField jTextMatricula;
    private javax.swing.JTextField jTextTelFijo;
    private javax.swing.JTextField jTextTelMovil;
    // End of variables declaration//GEN-END:variables

}
